# Contributor: Matt Dainty <matt+alpine@bodgit-n-scarper.com>
# Contributor: Dermot Bradley <dermot_bradley@yahoo.com>
# Maintainer: Dermot Bradley <dermot_bradley@yahoo.com>
pkgname=cloud-init
pkgver=20.2
pkgrel=1
pkgdesc="Cloud instance init scripts"
url="https://cloud-init.io"
# Dependant package "cloud-utils-growpart" is not available for mips,
# mips64, or s390x so disable these archs for this package too.
arch="noarch !mips !mips64 !s390x"
license="Apache-2.0 OR GPL-3.0-only"
depends="
	blkid
	cloud-utils-growpart
	e2fsprogs-extra
	eudev
	ifupdown
	iproute2-minimal
	python3
	py3-configobj
	py3-jinja2
	py3-jsonpatch
	py3-jsonschema
	py3-oauthlib
	py3-requests
	py3-six
	py3-yaml
	shadow
	sudo
	"
makedepends="py3-setuptools"
subpackages="$pkgname-doc $pkgname-bash-completion $pkgname-openrc"
source="https://launchpad.net/cloud-init/trunk/$pkgver/+download/cloud-init-$pkgver.tar.gz
	01-add-distro-alpine.patch
	02-add-to-util.patch
	03-add-to-cloud-cfg-template.patch
	04-add-to-render-cloudcfg.patch
	05-add-ca_certs-module-support.patch
	06-add-ntp-module-support.patch
	07-add-power_state-module-support.patch
	08-add-resolv_conf-module-support.patch
	alpine.py
	cc_apk_configure.py
	chrony.conf.alpine.tmpl
	hosts.alpine.tmpl
	interfaces
	ntp.conf.alpine.tmpl
	"

prepare() {
	default_prepare

	install -m644 \
		"$srcdir"/alpine.py \
		"$builddir"/cloudinit/distros/

	install -m644 \
		"$srcdir"/cc_apk_configure.py \
		"$builddir"/cloudinit/config/
}

build() {
	python3 setup.py build
}

check() {
	python3 setup.py check
}

package() {
	python3 setup.py install \
		--prefix=/usr --root="$pkgdir" --init-system=sysvinit_openrc

	install -m644 \
		"$srcdir"/*.tmpl \
		"$pkgdir"/etc/cloud/templates/

	mkdir -p \
		"$pkgdir"/etc/network
	install -m644 \
		"$srcdir"/interfaces \
		"$pkgdir"/etc/network/

	# Delete non-Alpine distribution template files
	for distro in \
		debian fedora freebsd opensuse redhat rhel sles suse ubuntu
	do
		for file in \
			"$pkgdir"/etc/cloud/templates/*."$distro".tmpl
		do
			rm "$file"
		done
	done

	# Delete systemd template file
	rm "$pkgdir"/etc/cloud/templates/timesyncd.conf.tmpl
}

sha512sums="2b63d435b162b6db232121959dc2e5fa59c7cc8916fca3bccb637dd5e583931930f6b4e0a22b961ee71058f518a090c0a636da8147b999acdaa06cd2fc3ee51c  cloud-init-20.2.tar.gz
4ab37323e7662445af90ce2654199fe3080e256571e8e12b121ebde791b98e68d368b10c5f22b7e8840c0ba9593dd0a6e37ec60724cd0ae4c806944a826741e3  01-add-distro-alpine.patch
5b6cba9da22c1b8d202170f215995abe22100251dee705219607cdadf32de498a3af56aab8324254f755ef0caa22f6a4e9fdcf8fc53dc4fde6757957a266405e  02-add-to-util.patch
236862f50c841704750109a1e4fe985bec6501554d8da33e1103fe35795c2ee566ae8d6b79cc2ec09160ec614fa61c09f1a778dea85d0e5e1ecb487d5f0d7fa0  03-add-to-cloud-cfg-template.patch
d92ea4aaf811a7338348054d8438051cf3f6a11e92b976f3b7c4d976f64de3144c97ec3c44a5691299eb499d0089b5a484a31bfa3d826fb44643185a76502c64  04-add-to-render-cloudcfg.patch
8dac6b6f176849760b2908f5597dd3b93f4b1803d13f4a068eebc3f23624b2a1050ff8fc6e7605db756bbf61aca9548384e9e3258bd3e7bd4bd6c339b68dd49e  05-add-ca_certs-module-support.patch
c3bb0ec13bfd572fa883b15a891d35f38a50bcfe8753896c774de2f4ce3c4e2ad0394e1a13cc89da154a8a7159aae9ef0c7451dbbed6deef33cb7f0fb61c6e6a  06-add-ntp-module-support.patch
34b37d7b10c43f35173d6f04a5f14bb811b84923b3417c819b4dc7ef46d63ad1c89cbd91c2da64ece2e9ee6f407e217b047bd118d6e2ca87367fb20f930dd264  07-add-power_state-module-support.patch
2871a0adfa70df2101b292829dc13f2b8a894b851b27d8f2579e3aebc598b849166f4dee9e27d0fda8680421f546c371c05a3526ea54606806bc288a95939ccc  08-add-resolv_conf-module-support.patch
df67a637d8127cdfe7cfaaa7d75ddf94e45834c72c7765b25155f83dc468d509709c7610211ddafa6e090bec2c9f28bc7cb0f8500bd10c44a598de32eb22985f  alpine.py
b92a1fd18b3ab07db3c17e83076fec0b47e5e238d634a7f59eae762fed38ce09d6c3965a7c03b94d392dbdce40ad0e06a862b9c37584443e8fe8725101cd6557  cc_apk_configure.py
f671ce6e54b8c6a1e3a1bd47fe93d380b1d12906be88891f00ee6e1f789bdc0ed38a777664cb1b7d6618a73e1dce47ee4f30d0831334f3bd3274aed11f063de4  chrony.conf.alpine.tmpl
45c62188d485ca5188a56c9db833036a1206da8a82a201fe8ef8a8fd9561ca111b6dd73f681086e757c775ca404e4dff6dbe83700f7f287a23f863f05e2314ac  hosts.alpine.tmpl
48b25ec4457c2b3772a7d210033551d041749a0d1869818d888030e6df7fd9bbc13a38b95cf465de3d46d96881a722f94a337584ce48f280c4a52b819586563a  interfaces
5a466452a5999c4bd1d88e6c9f3c88e4c2b6470eb6d0de7c5d1cc2880b767ac90cd9fe94d5ddd488c6838ca0b12f48187e35af794c7e8b27fef99f65151b5926  ntp.conf.alpine.tmpl"
